<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/materialdesignicons.min.css" rel="stylesheet">
		<!--标签插件-->
		<link rel="stylesheet" href="js/jquery-tags-input/jquery.tagsinput.min.css">
		<link href="css/style.min.css" rel="stylesheet">

		<link href="css/animate.css" rel="stylesheet">
	</head>

	<body>
		<div class="container-fluid p-t-15">

			<div class="row">
				<div class="col-lg-12">
					<div class="card">
						<div class="card-body">

							<form action="#!" method="post" class="row">
								<!-- <div class="col-md-5 col-md-offset-3"> -->
								<div class="col-md-5">
									<div class="form-group col-md-12">
										<label for="typeName">类别名称</label>
										<input type="text" class="form-control" id="typeName" name="typeName" value=""
											placeholder="请输入类别名称" />
									</div>
									<div class="form-group col-md-12">
										<label for="typeDesc">描述</label>
										<textarea class="form-control" id="typeDesc" name="typeDesc" rows="5" value=""
											placeholder="请输入类别描述"></textarea>
									</div>
									<div class="form-group col-md-12">
										<button onclick="addType()" type="button" class="btn btn-primary ajax-post"
											target-form="add-form">添加类别</button>
									</div>
								</div>
								
							</form>

						</div>
					</div>
				</div>

			</div>

		</div>

		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/bootstrap.min.js"></script>
		<!--标签插件-->
		<script src="js/jquery-tags-input/jquery.tagsinput.min.js"></script>
		<script type="text/javascript" src="js/main.min.js">

			<!--消息提示-->
			<script src="js/bootstrap-notify.min.js"></script>
		<script type="text/javascript" src="js/lightyear.js"></script>
		<script>
			function addType(){
				//1- 获取添加类别的信息
				let typeName = $("#typeName").val();
				let typeDesc = $("#typeDesc").val();
				//2- 封装提交参数
				let param = {
					"typeName": typeName,
					"typeDesc": typeDesc
				}

				//3- 请求添加
				$.getJSON("productTypes/add", param, function(rvo){
					console.log("productTypes/add", rvo);
					//添加失败
					if(rvo.code != 1){
						lightyear.notify(rvo.msg, "danger", 1000);
						return;
					}

					//添加成功，跳转到页面显示
					location.href = "./pro_type_list.html";

				});

			}



		</script>
	</body>
</html>
